package twu.shubham.library;

import java.util.Scanner;

public class Biblioteca {

    public static void main(String args[])
    {
        int toContinue = 1;
        int menuOption;
        int totalBooks =5;
        BookRecord[]  bookList =new BookRecord[totalBooks];
        bookList[0] = new BookRecord(2,"a");
        bookList[1] = new BookRecord(0,"b");
        bookList[2] = new BookRecord(1,"c");
        bookList[3] = new BookRecord(2,"d");
        bookList[4] = new BookRecord(4,"e");

        System.out.println("Welcome to Library system");

        while (toContinue==1)
        {
            System.out.println("Menu : \n1.See all the books\n2.Return a book\n3.See the membership detail\n enter an option");
            int bookNumber;
            Scanner input = new Scanner( System.in );
            menuOption = input.nextInt();

            if(menuOption==1)
            {
                  for(int i=0; i<totalBooks;i++)
                      bookList[i].bookPrint(i+1);

                System.out.println("Want to reserve a book : 1.Yes\n2.No\n");
                int reserveBook = input.nextInt();

                if(reserveBook==1)
                {
                    System.out.println("Enter the book number : ");

                    bookNumber = input.nextInt();

                    if((bookNumber > 0) && (bookNumber <= totalBooks))
                        bookList[bookNumber - 1].reserveBook(bookNumber);

                    else
                        System.out.println("Not a Valid book number\n");
                }

            }

            if(menuOption==2)
            {
                System.out.println("Enter the book number");
                bookNumber=input.nextInt();

                if((bookNumber <= totalBooks) && (bookNumber > 0))
                    bookList[bookNumber - 1].returnBook();

                else
                    System.out.println("Not a valid book number");
            }

            if(menuOption==3)
            {
                System.out.println("Contact Librarian\n");
            }

            System.out.println("Do You want to continue : 1.Yes\t2.No\n");
            toContinue=input.nextInt();

        }
    }
}
